<template>
  <div>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="420px" top="35vh" :close-on-click-modal="false" @close="close">
      <div class="tips">
        <!-- 会员开卡奖励积分 -->
        <div v-if="type==='award'">
          会员开卡是指顾客在开通你旗下的某一张会员卡时, 自动向这个会员赠送一定的积分, 如果需要配置请前往会员卡管理的
          <span class="app-text-color-primary">【开卡奖励】</span> 进行配置。
        </div>
        <!-- 会员充值奖励积分 -->
        <div v-if="type==='rights'">
          根据会员的充值金额奖励不同的积分，积分的运用可以激励顾客提升充值的金额，如果需要启用请前往会员卡管理的
          <span class="app-text-color-primary">【权益设置】</span>进行配置。
        </div>
        <div v-if="type==='promoters'">
          通过积分激励顾客或者会员为你拉新会员，如果需要启用请前往会员运营的
          <span class="app-text-color-primary">【推广员拉新】</span>的配置的进行配置。
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" round @click="hide">取 消</el-button>
        <el-button v-if="(type==='award'||type==='rights')&&!$store.getters.banBtnList.includes('BTN_MEMBER_CATEGORY_EDIT')" size="small" round type="primary" @click="handleSubmit()">去配置</el-button>
        <el-button v-if="type==='promoters'&&!$store.getters.banBtnList.includes('CARD_PROMOTER')" size="small" round type="primary" @click="handleSubmit()">去配置</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      resolve: null,
      reject: null,
      dialogVisible: null,
      title: null,
      type: null
    }
  },
  methods: {
    open(type) {
      this.type = type
      switch (type) {
        case 'award':
          this.title = '会员开卡奖励积分'
          break
        case 'rights':
          this.title = '会员充值奖励积分'
          break
        case 'promoters':
          this.title = '会员推广奖励积分'
          break
      }
      this.show()
      return new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
    },

    show() {
      this.dialogVisible = true
    },

    close() {},

    hide() {
      this.resolve = null
      this.reject = null
      this.dialogVisible = false
    },

    // 跳转
    handleSubmit() {
      switch (this.type) {
        case 'promoters':
          this.$router.push({
            name: 'VipPromoters',
            query: { type: 'config' }
          })
          break
        default:
          this.$router.push({
            name: 'VipCardList'
          })
          break
      }
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .tips {
    line-height: 24px;
  }
</style>
